﻿Imports DTO
Imports System.Linq

Public Class UserDAO
    Public Function getUser_DAO(ByVal us As String, ByVal mk As String, ByVal style As Integer) As Integer
        Dim result As Integer
        Dim listus As List(Of UserDTO) = New List(Of UserDTO)
        Dim context As DataproviderDataContext = New DataproviderDataContext()
        Dim list = From user In context.users
                   Where user.tenuser.Contains(us) And user.matkhau.Contains(mk) And user.style = style
                   Select user.tenuser, user.matkhau

        For Each value In list
            Dim entity As UserDTO = New UserDTO()
            entity.TenUser = value.tenuser
            entity.MatKhau = value.matkhau

            listus.Add(entity)
        Next

        If listus.Count = 0 Then
            result = 0
        Else
            result = 1
        End If

        Return (result)
    End Function
End Class
